package com.boot.security.server.controller.mffl.MfflUser;

import java.util.List;

import com.boot.security.server.model.mffl.MfflProfit;
import com.boot.security.server.utils.mffl.ReturnBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.boot.security.server.page.table.PageTableRequest;
import com.boot.security.server.page.table.PageTableHandler;
import com.boot.security.server.page.table.PageTableResponse;
import com.boot.security.server.page.table.PageTableHandler.CountHandler;
import com.boot.security.server.page.table.PageTableHandler.ListHandler;
import com.boot.security.server.dao.mffl.MfflUserDao;
import com.boot.security.server.model.mffl.MfflUser;

import com.boot.security.server.service.impl.mffl.MfflUser.mfflUserService;

import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/client/mfflUsers")
@Api(tags = "个人信息")
public class Client_MfflUserController {

    @Autowired
    private MfflUserDao mfflUserDao;

    @Autowired
    mfflUserService mfflUserservice;


    @GetMapping("getUserProfitP")
    @ApiOperation("获取个人支入支出情况")
    @ApiImplicitParams({
            @ApiImplicitParam(required = true, name = "offset", value = "开始条数", dataType = "int"),
            @ApiImplicitParam(required = true, name = "limit", value = "每页条数", dataType = "int"),
            @ApiImplicitParam(required = true, name = "settlement", value = "1已结算，0未结算(未结算,退款,申请退款)", dataType = "int")})
    public ReturnBean<MfflProfit> getUserProfitP(PageTableRequest request) {
        return mfflUserservice.getUserProfitP(request);
    }

    /*@PostMapping
    @ApiOperation(value = "保存")
    public MfflUser save(@RequestBody MfflUser mfflUser) {
        mfflUserDao.save(mfflUser);

        return mfflUser;
    }

    @GetMapping("/{id}")
    @ApiOperation(value = "根据id获取")
    public MfflUser get(@PathVariable Long id) {
        return mfflUserDao.getById(id);
    }

    @PutMapping
    @ApiOperation(value = "修改")
    public MfflUser update(@RequestBody MfflUser mfflUser) {
        mfflUserDao.update(mfflUser);

        return mfflUser;
    }

    @GetMapping
    @ApiOperation(value = "列表")
    public PageTableResponse list(PageTableRequest request) {
        return new PageTableHandler(new CountHandler() {

            @Override
            public int count(PageTableRequest request) {
                return mfflUserDao.count(request.getParams());
            }
        }, new ListHandler() {

            @Override
            public List<MfflUser> list(PageTableRequest request) {
                return mfflUserDao.list(request.getParams(), request.getOffset(), request.getLimit());
            }
        }).handle(request);
    }

    @DeleteMapping("/{id}")
    @ApiOperation(value = "删除")
    public void delete(@PathVariable Long id) {
        mfflUserDao.delete(id);
    }*/
}
